{include app:admin.inc.header}
<!--tmpl-resource-->
{include app:admin.inc.top}


<div class="container-fluid content-body">
	<div class="main">
		<!-- left side start-->
		{include admin.inc.menu}
		<!-- left side end-->


		<!-- main content start-->
		<section class="right-section" id="right-section">
			<!-- start of inner-frame -->
			<div class="inner-iframe">

				<!-- page breadcrumb start-->
				{include admin.inc.bread}
				<!-- page "breadcrumb end-->
				<!-- Nav tabs -->
				<ul class="nav nav-tabs">

					<li {if $id==''}class="active"{/if}><a {if $id==''}href="javascript:void(0);"{else}href="{$add_url}"{/if}><i class="glyphicon glyphicon-plus"></i> 添加单页表</a></li>
					{if $id != ''}<li class="active"><a href="javascript:void(0);"><i class="glyphicon glyphicon-edit"></i> 编辑单页</a></li>{/if}
					<li><a href="{$index_url}" ><i class="glyphicon glyphicon-th-list"></i> 单页列表</a></li>
					<li><a href="{url  admin/singlepageCate/index}"><i class="glyphicon glyphicon-th-list"></i> 单页类型</a></li>
					<li><a href="{url admin/singlepageCate/add}"><i class="glyphicon glyphicon-plus"></i>添加类型</a></li>
				</ul>
				<div class="inner-container">
					<form role="form" class="content-add-form form-horizontal" id="content-add-form" autocomplete="off">
						<input type="hidden" value="{$item.image_url}" name="data[old_image]" class="form-control">
						<!--tmpl-fields-->
						<!-- input -->
						<div class="form-group">
							<label class="col-sm-2 control-label">单页类型 </label>
							<div class="col-sm-4"><select name="data[cate_id]" class="form-control select2">
								{loop $singleCate $cate}
								<option {if $cate['id']==$item['cate_id']}selected{/if} value="{$cate.id}">{$cate.name}</option>
								{/loop}
							</select>
							</div>
						</div>
						<p class="help-block"></p>
						<div class="form-group">
							<label class="col-sm-2 control-label"><span class="asterisk">*</span>标题 </label>
							<div class="col-sm-4">
							<input  dtype="" class="form-control" maxlength="20" name="data[title]" placeholder="标题" required cname="标题" value="{$item[title]}" />
							<p class="help-block"></p>
							</div>
						</div>

						<!-- input -->
						<div class="form-group">
							<label class="col-sm-2 control-label">图片上传</label>
							<div class="col-sm-3">
								<div id="image-box" class="pull-left">
								</div>
								<div class="pull-left">
									<span name="image_url" class="img-upload text-center" id="upload">
										<i class="glyphicon glyphicon-picture"></i>
										<span class="upload-text"><i class="glyphicon glyphicon-plus">添加图片</i> </span>
										<input type="hidden" name="data[image_url]" id="cimg_url" value="{$item.image_url}">
									</span>
								</div>
							</div>
							<div class="col-sm-3">
								【图片比例为:760x470】
							</div>
						</div>
						<p class="help-block"></p>
						
						<!-- editor -->
						<div class="form-group">
							<label class="col-sm-2 control-label"><span	class="asterisk">*</span>单页内容</label>
							<div class="col-sm-8">
								<textarea class="form-control" cname="单页内容" required name="data[content]" id="editor-content" style="height:400px;visibility:hidden;">{$item[content]}</textarea>
								<p class="help-block"></p>
							</div>
						</div>


						<!-- input -->
						<div class="form-group">
							<label class="col-sm-2 control-label">单页简介 </label>
							<div class="col-sm-4">
								<textarea class="form-control" cname="单页简介" name="data[summary]"  placeholder="单页简介">{$item[summary]}</textarea>
							</div>
						</div>

						<div class="form-group">
							<label class="col-sm-2 control-label"><span	class="asterisk">*</span>排序</label>
							<div class="col-sm-4">
								<input  dtype="" class="form-control" maxlength="50" name="data[sort_index]" placeholder="50" required cname="排序" value="{if $item[sort_index]}{$item[sort_index]}{else}50{/if}" />
								<p class="help-block"></p>
							</div>
						</div>

						<div class="form-group">
							<label class="col-sm-2 control-label"><span
									class="asterisk">*</span>全屏显示/固定显示</label>
							<div class="col-sm-4">
								<input type="checkbox" id="switch-status" name="data[is_full]" class="bswitch"
									   data-size="small" {if $item[is_full]=='1'}checked{/if} data-on-text="全屏"  data-off-text="固定">

							</div>
						</div>
						<p class="help-block"></p>

						<div class="form-group">
							<label class="col-sm-2 control-label">操作人</label>
							<div class="col-sm-4" style="padding-top: 3px;">{$admin_name}</div>
						</div>
						<p class="help-block"></p>
						<!--tmpl-assocfields-->
						<div class="btn-group btn-group-or">
							<a href="{if $id==''}{$do_add_url}{else}{$do_edit_url}?id={$id}{/if}" class="btn btn-primary ajaxproxy"
								proxy='{"method":"post", "location":"{$index_url}"}'>提交保存</a>

						</div>
					</form><!-- content add form -->
				</div>
			</div><!-- end of inner -->
		</section>
	</div>
</div>
{include admin.inc.footer}
<!--tmpl-script-->
<!-- pagescript -->
<script type="text/javascript">
	seajs.use("admin/informationadd",function (parameter){
		/**--tmpl-templatejavascript--**/
		<!--tmpl-templatejavascript-->
		parameter.upload_url="{$upload_url}";
		parameter.image_search_url="{$image_search_url}";
		parameter.image_list_url="{$image_list_url}";
		parameter.init();
		parameter.upload({
			datas:['{$item.image_url}'],
			onSuccess : function(data) { //上传一张图片成功回调
				removeImage(data[data.length-2]);   ////当上传多张图片的时候，删除之前的所有图片
				if($("#image-box").children().length>1)		//如果有两张图片以上，才进行删除操作
				{
					$("#image-box").children(":first").remove();
				}
				$("#cimg_url").val(data[data.length-1]);
			},
			onRemove : function(data) {
				$("#cimg_url").val("");
				removeImage(data); //用户删除的时候，把图片也连带删除
			},
		});
	});
	function removeImage(data)
	{
		$.get("/admin/singlepage/del_img?image_url="+data,function(result){});
	}
</script>


<script id="assocpage" type="text/html">
<div class="text-right">
	<ul class="pagination blog-pagination">
		<li><a class="assoc-page" data-page="{[prev]}" href="javascript:void(0);">上一页</a></li> 
		{[loop pages page]}

		<li ><a class="assoc-page" data-page="{[page]}" {[if curr == page]}class="active"{[/if]} href="javascript:void(0)">{[page]}</a></li> 

		{[/loop]}
		<li><a class="assoc-page" href="javascript:void(0);" data-page="{[nexts]}">下一页</a></li> 
	</ul>	
</div>
</script>

</body>
</html>
